package com.ourteam.product.requirement.api;

import org.apache.commons.lang.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.requirement.dao.ProductRoleDefineDAOQueryBean;
import com.ourteam.product.requirement.domain.ProductRoleDefineBean;

public class ProductRoleDefineSearchModel extends AbstractSearchModel<ProductRoleDefineDAOQueryBean> {

	private String roleCode;

	private String roleName;

	private long productDefineId;

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductRoleDefineBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductRoleDefineDAOQueryBean queryBean) throws Exception {

		ProductRoleDefineDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (this.productDefineId != 0) {
			criteria.andProductDefineIdEqualTo(productDefineId);
		}

		if (StringUtils.isNotBlank(roleCode)) {
			criteria.andRoleCodeLike(roleCode);
		}

		if (StringUtils.isNotBlank(roleName)) {
			criteria.andRoleNameLike(roleName);
		}
	}

	public String getRoleCode() {
		return roleCode;
	}

	public void setRoleCode(String roleCode) {
		this.roleCode = roleCode;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public long getProductDefineId() {
		return productDefineId;
	}

	public void setProductDefineId(long productDefineId) {
		this.productDefineId = productDefineId;
	}

}
